package  com.rx.mgt.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.rx.mgt.dao.base.ManagementHibernateDaoBase;
import com.rx.mgt.domain.SysParam;

@Repository
public class SysParamDao  extends ManagementHibernateDaoBase<SysParam, Long>{
	@Transactional(readOnly=true)
	public SysParam getSysParamByKey(String group,String paramKey){
		String hql ="from  SysParam an where an.status='1' and an.group=:group and an.paramKey=:paramKey";
		Query query = template.getSessionFactory().getCurrentSession().createQuery(hql);
		query.setParameter("group", group);
		query.setParameter("paramKey", paramKey);
		@SuppressWarnings("unchecked")
		List<SysParam> list= query.list();
		if(list!=null&&list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
	}
}
